﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace d2.随机数LINQ排序
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>();
            Random random = new Random();
            Console.WriteLine("排序前的元素：");
            for (int i = 1; i <= 100; i++)
            {
                list.Add(random.Next(1000));
                Console.Write(list[i-1] + " ");
                if (i % 20 == 0)
                    Console.WriteLine();
            }
            list = list.OrderByDescending (x => x).ToList();
            Console.WriteLine("排序后的元素：");
            for (int i = 1; i <= 100; i++)
            {
                Console.Write(list[i-1] + " ");
                if (i % 20 == 0)
                    Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine("和为：" + list.Sum());
            Console.WriteLine("平均数为：" + (float)list.Sum()/list.Count());
        }
    }
}
